function ajax_handler(type,url,func,post_str) {
    if (window.XMLHttpRequest) {
        xmlobj= new XMLHttpRequest();
    }
    else {
        xmlobj = new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlobj.onreadystatechange=func;

    xmlobj.open(type,url,true);
    xmlobj.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlobj.send(post_str);
}

function checkacc(type) {
    var name = document.forms['register']['username'].value;
    if (name.length==0) document.getElementById("warning").innerHTML = "";
    else
        ajax_handler("POST", "modules/check_account.php", function () {
            if (xmlobj.readyState==4 && xmlobj.status==200)
                document.getElementById("warning").innerHTML = xmlobj.responseText;
        },"name="+name+"&type="+type);
}